/*
 * Copyright (c) 2012 Sean Connelly
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
 * associated documentation files (the "Software"), to deal in the Software without restriction,
 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or
 * substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
 * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

var path = require('path');
var root_dir = path.dirname(process.argv[1]);

function makeTest(test_list)
{
	require(path.resolve(root_dir, 'test/main.js'))
		.run(root_dir, test_list);
}

function makeAll()
{
	console.log('not implemented');
}

//
// main execution begins here
//

var main_cmd = typeof process.argv[2] != 'undefined' ? process.argv[2] : 'all';
switch (main_cmd)
{
case 'all':
	makeAll();
	break;

case 'test':
	var test_list = false;
	// gather tests if specified
	if (process.argv.length > 3)
	{
		test_list = [];
		for (var i = 3; i < process.argv.length; i++)
			test_list.push(process.argv[i]);
	}

	// make the tests specified (or false for all tests)
	makeTest(test_list);
	break;

default:
	console.log('unknown command: ' + main_cmd);
	break;
}

